home *** CD-ROM | disk | FTP | other *** search
- Unit XManager;
- {$R-,S-.O+}
-
- { The Manager Object provides the ExtendedTable with information on all }
- { Lobes of the ExtendedArray. The priority, loaded status and diskfile name }
- { are all tracked by the Manager. In the case where the searched for Lobe }
- { is already loaded into one of the ExtendedTable's buffers, the array }
- { address is stored as well. By consulting the Manager, the Table can }
- { always provide the needed Lobe to the ExtendedArray. }
-
- INTERFACE
-
- Uses GenArray,XGlobals;
-
- Type
- ManRec = Record
- Tag : Short;
- Loaded : Boolean;
- Address : Byte;
- Pri : LongInt;
- {Address in 0..MaxBuff implies Loaded
- Address of MaxBuff+1 implies Not Loaded}
- End;
-
- Manager = Object (FlexArray)
-
- {
- Procedure Create;
- Procedure Destroy;
- }
-
- Procedure Init (NumLobes : Word);
- Procedure SetTag (Index : Word; Tag : Short);
- Procedure Load (Index : Word; Address : Byte);
- Procedure UnLoad (Index : Word);
-
- Function ManIndex (Tag : Short) : Word;
- Function MemIndex (Index : Word) : Byte;
- Function GetTag (Index : Word) : Short;
- Function PriIndex (Index : Word) : LongInt;
- Function InMem (Index : Word) : Boolean;
-
- {
- Function MaxSize : Word;
- }
- End;
-
- IMPLEMENTATION
-
- Procedure Manager.Init (NumLobes : Word);
- Var
- M : ManRec;
- I : Word;
- Begin
- FlexArray.Init (NumLobes,SizeOf(ManRec));
- For I := 0 to NumLobes-1 do
- Begin
- Retrieve (M,I,SizeOf(M));
- M.Tag := '';
- M.Loaded := False;
- M.Address := MaxBuff+1;
- M.Pri := 0;
- Accept (M,I,SizeOf(M))
- End
- End;
-
- Procedure Manager.SetTag (Index : Word; Tag : Short);
- Var
- M : ManRec;
- Begin
- Retrieve (M,Index,SizeOf(M));
- M.Tag := Tag;
- Accept (M,Index,SizeOf(M))
- End;
-
- Procedure Manager.Load (Index : Word; Address : Byte);
- Var
- M : ManRec;
- Begin
- Retrieve (M,Index,SizeOf(M));
- M.Loaded := True;
- M.Address := Address;
- M.Pri := M.Pri + 1; {Increment Priority for Indexth Lobe each time
- it must be loaded from disk.}
- Accept (M,Index,SizeOf(M))
- End;
-
- Procedure Manager.UnLoad (Index : Word);
- Var
- M : ManRec;
- Begin
- Retrieve (M,Index,SizeOf(M));
- M.Loaded := False;
- M.Address := MaxBuff+1;
- Accept (M,Index,SizeOf(M))
- End;
-
- Function Manager.GetTag (Index : Word) : Short;
- Var
- M : ManRec;
- Begin
- Retrieve (M,Index,SizeOf(M));
- GetTag := M.Tag;
- End;
-
- Function Manager.ManIndex (Tag : Short) : Word;
- Var
- M : ManRec;
- T : Short;
- I : Word;
- Begin
- I := 0;
- T := GetTag (I);
- While T <> Tag do
- Begin
- I := I + 1;
- T := GetTag (I)
- End;
- ManIndex := I
- End;
-
- Function Manager.MemIndex (Index : Word) : Byte;
- Var
- M : ManRec;
- Begin
- Retrieve (M,Index,SizeOf(M));
- MemIndex := M.Address;
- End;
-
- Function Manager.PriIndex (Index : Word) : LongInt;
- Var
- M : ManRec;
- Begin
- Retrieve (M,Index,SizeOf(M));
- PriIndex := M.Pri;
- End;
-
- Function Manager.InMem (Index : Word) : Boolean;
- Var
- M : ManRec;
- Begin
- Retrieve (M,Index,SizeOf(M));
- InMem := M.Loaded
- End;
-
- BEGIN
- END.